Text to Image API Documentation
Text Validation Endpoint
- Method: POST
- Path:
https://api.kadal.ai/text-to-image/api/v1/text_validation - Summary: Validates input text for suitability in image generation.
Description
This endpoint verifies that the provided text is well-formed and interpretable, ensuring it can be processed effectively to generate a corresponding image.
Request
- Content-Type: multipart/form-data
Payload
| Parameter | Description | Data Type | Is Optional |
|---|---|---|---|
| input_text | Text corresponding to which an image needs to be generated | String | No |
Response
Success (200 OK)
{
"status_code": 200,
"message": "SUCCESS::Text Validation generated successfully",
"input_text": "Your input text result will appear here"
}
Usage
import requests
url = "https://api.kadal.ai/text-to-image/api/v1/text_validation"
token = "your_token_here"
headers = {
"accept": "application/json",
"Authorization": f"Bearer {token}",
"Content-Type": "application/x-www-form-urlencoded",
}
data = {
"input_text": """A paper craft art depicting a girl giving her cat a gentle hug. Both sit amidst potted plants, with the cat purring contentedly while the girl smiles. The scene is adorned with handcrafted paper flowers and leaves."""
}
response = requests.post(url, headers=headers, data=data)
Text to Image Generation Endpoint
- Method: POST
- Path:
https://api.kadal.ai/text-to-image/api/v1/text_to_image - Summary: Generates images from text with configurable count and aspect ratio.
Description
This endpoint generates images from input text using a selected AI model, with options to set the number of images and aspect ratio.
Request
- Content-Type: multipart/form-data
Payload
| Parameter | Description | Data Type | Constraints / Allowed Values | Optional |
|---|---|---|---|---|
| user_model_selection | AI model used for generation | String | Must be one of: dall-e-3 | No |
| input_text | Input text prompt | String | Non-empty; max length: 300 chars | No |
| number_of_images | Number of images to generate | String | Range: 1–3 | No |
| aspect_ratio | Aspect Ratio of images | String | Must be one of: 1:1, 16:9, 9:16 | No |
Response:
{
"status_code": 200,
"message": "SUCCESS::Text to Image generated successfully",
"images_created": {
"image_url_1": "Your image_url will appear here",
"image_url_2": "Your image_url will appear here",
"image_url_3": "Your image_url will appear here"
}
}
Usage
import requests
url = "https://api.kadal.ai/text-to-image/api/v1/text_to_image"
token = "your_token_here"
headers = {
"accept": "application/json",
"Authorization": f"Bearer {token}",
"Content-Type": "application/x-www-form-urlencoded",
}
data = {
"user_model_selection": "dall-e-3",
"input_text": """A paper craft art depicting a girl giving her cat a gentle hug. Both sit amidst potted plants, with the cat purring contentedly while the girl smiles. The scene is adorned with handcrafted paper flowers and leaves.""",
"number_of_images": "3",
"aspect_ratio": "1:1",
}
response = requests.post(url, headers=headers, data=data)